package com.yykj.user.center.server.schedule;

import com.yykj.user.center.server.service.patient.ConsultationInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * @author chenl
 * @version 1.0
 * @date 2021/11/15 22:13
 */
@Component
@EnableScheduling   // 1.开启定时任务
@EnableAsync        // 2.开启多线程
@Slf4j
public class ConsultationInfoOrderTask {
    @Autowired
    private ConsultationInfoService consultationInfoService;

    /**
     * 自动结束问诊
     * @throws InterruptedException
     */
    @Async
    @Scheduled(cron = "0 */1 * * * ?")
    public void complete() throws InterruptedException {
        log.info("开始执行每分钟定时任务，结束问诊。");
        consultationInfoService.complete();
    }
}
